/**
 * 
 */
package com.wy2.generator.test;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

import cn.xo68.core.PropertiesDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import com.wy2.generator.GenerateResult;
import com.wy2.generator.GeneratorByJdbcConnection;

import com.wy2.generator.config.GeneratorConsts;
import com.wy2.generator.resource.Messages;

/**
 * @author nnsword
 * @date 2017-12-20 21:39:19
 *
 */
public class GeneratorByJdbcConnectionTest2 {
	private static final Logger logger=LoggerFactory.getLogger(GeneratorByJdbcConnectionTest2.class);
	/**
	 * @date 2017-12-20 21:39:19
	 * @param args
	 */
	public static void main(String[] args) {
		PropertiesDocument prop=new PropertiesDocument(true);
        try {
            String path="generator-config-jdbc-contection.xml";
            prop.loadAndMerge(DemoTest.class.getClassLoader(), false, path);
        } catch (IOException e) {
            logger.error(Messages.getString("RuntimeError.2"),e);
            return;
        }
        

        
        GeneratorByJdbcConnection generatorByJdbcConnection=new GeneratorByJdbcConnection(prop);
        Map<String,Object> model=new HashMap<>();
        model.put(GeneratorConsts.TEMPLATE_ATTRI_PROJECT_NAME,"project-name");
        model.put(GeneratorConsts.TEMPLATE_ATTRI_GROUP_ID,"com.wy2");
        model.put(GeneratorConsts.TEMPLATE_ATTRI_ARTIFACT_ID,"wy2-generator");
        model.put(GeneratorConsts.TEMPLATE_ATTRI_MODULE,"");
        model.put(GeneratorConsts.TEMPLATE_ATTRI_BASEPACKAGE, "com.wy2.generator.test");
        LinkedList<GenerateResult> generateResults = generatorByJdbcConnection.generte(null, model, true);
        
        logger.info("{}",generatorByJdbcConnection.getOutputRootDirectory());
        generateResults.forEach(result->{
        	logger.info("{} - {} - {}",result.getMarker(),result.getSuccess(),result.getGenerateFilePath());
        });

	}

}
